home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3006
/
3006.xpi
/
chrome
/
dwhelper.jar
/
content
/
ythq-widgets.xml
< prev
Wrap
Extensible Markup Language
|
2010-01-15
|
7KB
|
249 lines
<?xml version="1.0"?>
<!-- *****************************************************************************
* Copyright (c) 2006-2007 Michel Gutierrez. All Rights Reserved.
****************************************************************************** -->
<!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="YTHQConfiguration" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox flex="1">
<tree anonid="xTree" hidecolumnpicker="true" flex="3" onselect="this.parentNode.parentNode.selected()">
<treecols>
<treecol label="&ythq.column.type;" flex="1"/>
<treecol label="&ythq.column.format;" flex="1"/>
<treecol label="&ythq.column.video;" flex="3"/>
<treecol label="&ythq.column.audio;" flex="2"/>
</treecols>
<treechildren anonid="xChildren"/>
</tree>
<vbox flex="1" style="height: 60px; overflow: auto;">
<spacer flex="1"/>
<button anonid="xEnableBut" label="&ythq.label.enable;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.changeState(1)"/>
<button anonid="xDisableBut" label="&ythq.label.disable;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.changeState(0)"/>
<button anonid="xUpBut" label="&ythq.label.up;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.move(1)"/>
<button anonid="xDownBut" label="&ythq.label.down;" collapsed="true" oncommand="this.parentNode.parentNode.parentNode.move(0)"/>
</vbox>
</hbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.formats={
6: { type: "6", format: "FLV", video: "480x270", audio: "mono" },
13: { type: "13", format: "3GP", video: "176x144", audio: "mono" },
17: { type: "17", format: "3GP", video: "176x144", audio: "stereo" },
18: { type: "18", format: "MP4", video: "480x360", audio: "stereo" },
34: { type: "34", format: "FLV", video: "320x240", audio: "mono" },
35: { type: "35", format: "FLV", video: "640x360", audio: "mono" },
22: { type: "22", format: "MP4", video: "1280x720", audio: "stereo" },
37: { type: "37", format: "MP4", video: "1920x1080", audio: "stereo" },
}
this.formatsCount=0;
for(var i in formats)
this.formatsCount++;
this.build("");
]]>
</constructor>
<property name="value">
<setter>
<![CDATA[
this.build(val);
]]>
</setter>
<getter>
<![CDATA[
var values=[];
var item=this.xChildren.firstChild;
while(item) {
if(item.getAttribute("properties")!="format-disabled")
values.push(item.getAttribute("format"));
item=item.nextSibling;
}
return values.join(",");
]]>
</getter>
</property>
<property name="selectedFormat">
<setter>
<![CDATA[
if(val==null)
this.xTree.view.selection.select(-1);
else {
var items=this.xChildren.childNodes;
for(var i=0;i<items.length;i++) {
if(items.item(i).getAttribute("format")==val) {
this.xTree.view.selection.select(i);
return;
}
}
}
]]>
</setter>
<getter>
<![CDATA[
if(this.xTree.currentIndex<0)
return null;
return this.xChildren.childNodes.item(this.xTree.currentIndex).getAttribute("format");
]]>
</getter>
</property>
<method name="build">
<parameter name="aValue"/>
<body>
<![CDATA[
var selection=this.selectedFormat;
while(this.xChildren.firstChild)
this.xChildren.removeChild(this.xChildren.firstChild);
var values=aValue.split(",");
var enabledValues={};
for(var i in values) {
this.buildRow(values[i],true);
enabledValues[values[i]]="";
}
for(var i in this.formats) {
if(enabledValues[i]==null)
this.buildRow(i,false);
}
this.selectedFormat=selection;
this.updateButtons();
]]>
</body>
</method>
<method name="buildRow">
<parameter name="format"/>
<parameter name="enabled"/>
<body>
<![CDATA[
if(this.formats[format]) {
var treeItem=document.createElement("treeitem");
treeItem.setAttribute("format",format);
this.xChildren.appendChild(treeItem);
var treeRow=document.createElement("treerow");
treeItem.appendChild(treeRow);
var treeCell=document.createElement("treecell");
treeCell.setAttribute("label",this.util.getFText("label.high-quality-prefix2",[this.formats[format].type],1));
treeRow.appendChild(treeCell);
var treeCell=document.createElement("treecell");
treeCell.setAttribute("label",this.formats[format].format);
treeRow.appendChild(treeCell);
var treeCell=document.createElement("treecell");
treeCell.setAttribute("label",this.formats[format].video);
treeRow.appendChild(treeCell);
var treeCell=document.createElement("treecell");
treeCell.setAttribute("label",this.formats[format].audio);
treeRow.appendChild(treeCell);
this.applyState(treeItem,enabled);
}
]]>
</body>
</method>
<method name="selected">
<body>
<![CDATA[
this.updateButtons();
]]>
</body>
</method>
<method name="updateButtons">
<body>
<![CDATA[
if(this.xTree.currentIndex<0) {
this.xUpBut.setAttribute("collapsed","true");
this.xDownBut.setAttribute("collapsed","true");
this.xEnableBut.setAttribute("collapsed","true");
this.xDisableBut.setAttribute("collapsed","true");
} else {
if(this.xTree.currentIndex>0)
this.xUpBut.setAttribute("collapsed","false");
else
this.xUpBut.setAttribute("collapsed","true");
if(this.xTree.currentIndex<this.formatsCount-1)
this.xDownBut.setAttribute("collapsed","false");
else
this.xDownBut.setAttribute("collapsed","true");
var selItem=this.xChildren.childNodes.item(this.xTree.currentIndex);
if(selItem.getAttribute("properties")=="format-disabled") {
this.xEnableBut.setAttribute("collapsed","false");
this.xDisableBut.setAttribute("collapsed","true");
} else {
this.xEnableBut.setAttribute("collapsed","true");
this.xDisableBut.setAttribute("collapsed","false");
}
}
]]>
</body>
</method>
<method name="changeState">
<parameter name="state"/>
<body>
<![CDATA[
var selItem=this.xChildren.childNodes.item(this.xTree.currentIndex);
this.applyState(selItem,state);
this.fireEvent("changed");
]]>
</body>
</method>
<method name="applyState">
<parameter name="element"/>
<parameter name="state"/>
<body>
<![CDATA[
if(state)
element.removeAttribute("properties");
else
element.setAttribute("properties","format-disabled");
element=element.firstChild;
while(element) {
this.applyState(element,state);
element=element.nextSibling;
}
]]>
</body>
</method>
<method name="move">
<parameter name="direction"/>
<body>
<![CDATA[
var selItem=this.xChildren.childNodes.item(this.xTree.currentIndex);
var selection=this.selectedFormat;
var refItem;
if(direction) {
refItem=selItem.previousSibling;
} else {
refItem=selItem.nextSibling.nextSibling;
}
this.xChildren.removeChild(selItem);
this.xChildren.insertBefore(selItem,refItem);
this.selectedFormat=selection;
this.fireEvent("changed");
]]>
</body>
</method>
</implementation>
</binding>
</bindings>